<%@ Language=VBScript %>
<%Option Explicit%>
<%
Response.Expires=0

if Session("UserName") = "" then
	response.Redirect "Login.asp"
end if
%>

<!--#include file="../cons.asp"-->
<!--#include file="../../Common/Database.asp"-->

<%
Dim FirmaHabilitada
FirmaHabilitada = GetFirmaHabilitada()
%>
<script src="../../js/prototype.js" type="text/javascript"></script>

<style type='text/css'>
	.pullDownTable{border-collapse: collapse; width:130px; background-color:#E7E7C5;}
	.pullDownTD{cursor: hand; width:130px; height:20px; border:1px solid #adadad;font:normal 11px Verdana;color:#666666;}
	.pullDownTDSS1{cursor: hand; width:120px; height:20px; border-left: 1px solid #adadad; border-top: 1px solid #adadad; border-bottom: 1px solid #adadad; font:normal 11px Verdana;color:#666666;}
	.pullDownTDSS2{cursor: hand; width:10px; height:20px; border-top: 1px solid #adadad; border-right: 1px solid #adadad; border-bottom: 1px solid #adadad; font:normal 11px Verdana;color:#666666;}
</style>

<html>
<body bgcolor="#d4d4c0" style="margin: 0px;">
<center>
<br>
<table cellpadding="0" cellspacing="0" width=95% style="border-collapse: collapse; font-family: Verdana; font-size: 0px;">
<tr>
	<td style="background-image: url(../../images/sup_izq.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
	<td style="border-top: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
	<td style="background-image: url(../../images/sup_der.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
</tr>
<tr>
	<td style="border-left: solid 1px #909090; background-color: #FCFCE4;" height=50>&nbsp;</td>
	<td style="background-color: #FCFCE4;">
		<table cellpadding="0" cellspacing="0" width=100% height=100% style="border-collapse: collapse; font-family: Verdana; font-size: 12px;">
			<tr>
				<td valign="top" style="font-weight: bold;">Curso:</td>
				<td valign="top" style="font-weight: bold;">Tipo:</td>
				<td valign="top" style="font-weight: bold;">Quincenas:</td>
			</tr>
			<tr>
				<td valign="top"><%=GetComboCursos()%></td>
				<td valign="top"><%=GetComboFirma()%></div></td>
				<td valign="top"><%=GetComboQuincenas()%></td>
			</tr>
		</table>
	</td>
	<td style="border-right: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
</tr>
<tr>
	<td style="background-image: url(../../images/inf_izq.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
	<td style="border-bottom: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
	<td style="background-image: url(../../images/inf_der.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
</tr>
</table>
<br>
<table cellpadding="0" cellspacing="0" width=50% style="border-collapse: collapse; font-family: Verdana; font-size: 0px;">
<tr>
	<td width="100%" valign="top" align="center">
		<table cellpadding="0" cellspacing="0" width=90% style="border-collapse: collapse; font-family: Verdana; font-size: 0px;" ID="Table1">
		<tr>
			<td style="background-image: url(../../images/sup_izq.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
			<td style="border-top: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
			<td style="background-image: url(../../images/sup_der.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
		</tr>
		<tr>
			<td style="border-left: solid 1px #909090; background-color: #FCFCE4;" height=50>&nbsp;</td>
			<td style="background-color: #FCFCE4;">
				<table cellpadding="0" cellspacing="0" width=100% height=100% style="border-collapse: collapse; font-family: Verdana; font-size: 12px;" ID="Table2">
					<tr>
						<td valign="top" style="font-weight: bold;">Listado de Alumnos</td>
					</tr>
					<tr>
						<td valign="top" align="center"><div id="divAlumnosFirmas" style="width: 400px; height: 200px;"></div></td>
					</tr>
				</table>
			</td>
			<td style="border-right: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
		</tr>
		<tr>
			<td style="background-image: url(../../images/inf_izq.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
			<td style="border-bottom: solid 1px #909090; background-color: #FCFCE4;">&nbsp;</td>
			<td style="background-image: url(../../images/inf_der.gif); background-repeat: no-repeat; width: 12px; height: 12px;"></td>
		</tr>
		</table>
	</td>
</tr>
</table>
<%
Private function GetComboCursos()

	Dim oConn, sSQL, oRS
	Dim count	' para saber si es la primera vez que entra al while
	
	Set oConn = OpenConnection
	
	sSQL = "select * from Curso order by CursoDescrip"
	
	Set oRS = oConn.Execute(sSQL)

	response.Write "<select id=""cmb_Cursos"" style=""font-family: Verdana; font-size: 10px;"" onchange=""GetAlumnosxFirmas(this.value, cmb_FnoF.value, cmb_Quincenas.value);"">"
	while not oRS.EOF
		response.Write "<option "
		if count=0 then
			response.Write "selected"
			count=1
		end if
		response.Write " value='" & oRS("IdCurso") & "'>"
		response.Write oRS("CursoDescrip")
		response.Write "</option>"
		oRS.MoveNext()
	wend
	response.Write "</select>"
End function

Private function GetFirmaHabilitada()
	Dim oConn, sSQL, oRS
	Dim count	' para saber si es la primera vez que entra al while
	
	Set oConn = OpenConnection
	
	sSQL = "select * from Variables where NombreVariable = 'FirmaHabilitada'"
	
	Set oRS = oConn.Execute(sSQL)
	
	if not oRS.EOF then
		GetFirmaHabilitada = cint(oRS("Valor"))
	else
		GetFirmaHabilitada = 1
	end if
end function

Private function GetComboQuincenas()
	Dim oConn, sSQL, oRS
	Dim aux		' para saber si es la primera vez que cambia la quincena
	
	Set oConn = OpenConnection
	
	sSQL = "select * from ColegioQuincena"
	
	Set oRS = oConn.Execute(sSQL)

	response.Write "<select id=""cmb_Quincenas"" style=""font-family: Verdana; font-size: 10px;"" onchange=""GetAlumnosxFirmas(cmb_Cursos.value, cmb_FnoF.value, this.value);"">"
	
	while not oRS.EOF
		'100 primera nota cuatrimestral
		'200 segunda nota cuatrimestral
		'501 promedio primer trimestre
		'502 promedio segundo trimestre
		'503 promedio tercer trimestre
		'123 promedio trimestres
		'1000 examen diciembre
		'2000 examen marzo
		'3000 promedio final
		if oRS("Trimestre") = 2 and aux=0 then
			response.Write "<option "
			if FirmaHabilitada=501 then
				response.Write "selected "
				
			end if
			response.Write "value='501'>1er Trimestre"
			response.Write "</option>"
			aux=1
		end if
		if oRS("Trimestre") = 3 and aux=1 then
			response.Write "<option "
			if FirmaHabilitada = 100 then
				response.Write "selected "
				
			end if
			response.Write "value='100'>1er Nota Cuatrimestral"
			response.Write "</option>"	
			response.Write "<option "
			if FirmaHabilitada=502 then
				response.Write "selected "
				
			end if
			response.Write "value='502'>2do Trimestre"
			response.Write "</option>"		
			aux=2
		end if
		response.Write "<option "
		if FirmaHabilitada=oRS("IdColegioQuincena") then
			response.Write "selected "
			
		end if
		response.Write " value='" & oRS("IdColegioQuincena") & "'>"
		response.Write "Trimestre " & oRS("Trimestre") & "|Quincena " & oRS("IdQuincena") & " (" & oRS("FechaDesde") & " - " & oRS("FechaHasta") & ")"
		response.Write "</option>"
		oRS.MoveNext()
	wend
		response.Write "<option "
		if FirmaHabilitada=200 then
			response.Write "selected "
			
		end if
		response.Write "value='200'>2da Nota Cuatrimestral"
		response.Write "</option>"	

		response.Write "<option "
		if FirmaHabilitada=503 then
			response.Write "selected "
			
		end if
		response.Write "value='503'>3er Trimestre"
		response.Write "</option>"

		response.Write "<option "
		if FirmaHabilitada= 123 then
			response.Write "selected "
			
		end if
		response.Write "value='123'>Promedio Trimestres"
		response.Write "</option>"	

		response.Write "<option "
		if FirmaHabilitada= 1000 then
			response.Write "selected "
			
		end if
		response.Write "value='1000'>EXAMEN DICIEMBRE"
		response.Write "</option>"	

		response.Write "<option "
		if FirmaHabilitada=2000 then
			response.Write "selected "
			
		end if
		response.Write "value='2000'>EXAMEN MARZO"
		response.Write "</option>"

		response.Write "<option "
		if FirmaHabilitada=3000 then
			response.Write "selected "
			
		end if
		response.Write "value='3000'>PROMEDIO FINAL"
		response.Write "</option>"		
	response.Write "</select>"
End function

Private function GetComboFirma()
	response.Write "<select id=""cmb_FnoF"" style=""font-family: Verdana; font-size: 10px;"" onchange=""GetAlumnosxFirmas(cmb_Cursos.value, this.value, cmb_Quincenas.value);"">"
	response.Write "<option value='2'>TODAS</option>"
	response.Write "<option selected value='0'>Sin Firmar</option>"
	response.Write "<option value='1'>Firmadas</option>"
	response.Write "</select>"
End function

%>


<script>

function GetAlumnosxFirmas(IdCurso, FnoF, IdQuincena)
{
	new Ajax.Request('AJAX_GetAlumnosxFirmas.asp?IdCurso='+IdCurso+'&FnoF='+FnoF+'&IdQuincena='+IdQuincena,{
								method:'get',
								onSuccess:	function(transport)
											{
												//alert(transport.responseText);
												var response = transport.responseText || "no response text";       
												//alert("Success! \n\n" + response);
												divAlumnosFirmas.innerHTML = response;
											},
								onFailure: function()
											{
													alert('No hay datos...');
											}   
								}
					); 
}

GetAlumnosxFirmas(1, 0, <%=FirmaHabilitada%>);

function FirmarEnPantalla(idAlumno, idSedeCurso)
{
	window.open("FirmarEnPantalla_R.asp?idAlumno="+idAlumno+"&idSedeCurso="+idSedeCurso+"&CuyExtraCu=1", "EnPantalla", "top=0, left=0, width=1020, height=650, toolbar=1, scrollbars=1");
}

function PopupEvAlumno(idAlumno, idSedeCurso, IdMateria)
{
	window.open("PopupEvAlumno.asp?idAlumno="+idAlumno+"&idSedeCurso="+idSedeCurso+"&IdMateria="+IdMateria, "PopupEvAlumno", "top=0, left=0, width=600, height=400, toolbar=0");
}
</script>
</center>
</body>
</html>